package com.sdau.repairmaster.UIFile;

import androidx.appcompat.app.AppCompatActivity;

import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.widget.Button;
import android.widget.TextView;

import com.sdau.repairmaster.R;

public class MainActivity extends AppCompatActivity {


    private Button mbtnLogin;
    private TextView text;
    int time = 3;

    //倒计时函数
    Handler handler = new Handler(){
        public void handleMessage(Message msg) {
            super.handleMessage(msg);
            if (time>0){
                text.setText(time -- + " S");
                handler.sendEmptyMessageDelayed(100,1000);
            }else{
                Intent intent = new Intent(MainActivity.this,LoginActivity.class);
                startActivity(intent);
                finish();
            }
        }
    };

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        //获取id
        text = findViewById(R.id.main_time);
        handler.sendEmptyMessage(100);



    }



}